/**
 * 一二级分类系数展示
 * @author linfeng
 * @since 2019/11/19
 */
layui.define(['index', 'form', 'table', 'laypage', 'layedit', 'laydate'], function (exports) {
    var $ = layui.$;
    var form = layui.form;
    var layer = layui.layer;
    var table = layui.table;
    var element = layui.element;

    table.init('zmn-table', {
        limit: json.size,
        page: false,
        toolbar: "#zmn-table-tool",
        defaultToolbar: [],
        done: function (res, curr, count) {
            //添加按钮
            let hasHelpBtn = $('[lay-event=CUSTOM_HELP]').length !== 0;
            if (!hasHelpBtn) {
                $(".layui-table-tool-self").prepend(toolbar_help.innerHTML);
            }
        }
    });

    /**
     * 封装的tips，适配laytable的配色，点击提示框外会关闭提示（layer.tips无法点击空白处隐藏tips）
     * @param html 提示内容
     * @param ele 绑定对象
     */
    function tips(html, ele) {
        let style = document.createElement("style");
        style.appendChild(document.createTextNode("    /*帮助提示框*/\n" +
            "    body .zmn-tips {\n" +
            "\n" +
            "    }\n" +
            "\n" +
            "    body .zmn-tips .layui-layer-content {\n" +
            "        color: #0C0C0C;\n" +
            "        background-color: #e6e6e6;\n" +
            "        padding-right: 3px;\n" +
            "        width: 396px;\n" +
            "        height: 300px;\n" +
            "        overflow-x: hidden;\n" +
            "        overflow-y: scroll;\n" +
            "    }\n" +
            "\n" +
            "    body .zmn-tips .layui-layer-content::-webkit-scrollbar-track {\n" +
            "        background-color: #e6b31a;\n" +
            "    }\n" +
            "\n" +
            "    body i.layui-layer-TipsB, i.layui-layer-TipsT, i.layui-layer-TipsL, i.layui-layer-TipsR, i.layui-layer-TipsG {\n" +
            "        border-right-color: #e6e6e6;\n" +
            "    }\n" +
            "\n" +
            "    body .layui-layer-tips i.layui-layer-TipsB, .layui-layer-tips i.layui-layer-TipsT {\n" +
            "        border-right-color: #e6e6e6;\n" +
            "    }"));
        let head = document.getElementsByTagName("head")[0];
        head.appendChild(style);
        layui.layer.open({
            type: 4
            , closeBtn: false
            , shade: 0.0001
            , tips: 1
            , skin: 'zmn-tips'
            , shadeClose: true
            , content: [html, ele]
        });
    }

    // 表格操作按钮
    table.on("toolbar(zmn-table)", function (obj) {
        if (obj.event === 'CUSTOM_HELP') {
            tips(help_content.innerHTML, this);
        }
    });

    //对外暴露的接口
    exports('brand_ratio_classify', {});
});